<template>
    <a-form ref="formRef" :model="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 18 }">
        <a-form-item label="职务编码" :rules="rules.code" name="code">
            <a-input v-model:value="form.code" placeholder="请输入职务编码" :disabled="disabled" />
        </a-form-item>
        <a-form-item label="职务名称" :rules="rules.name" name="name">
            <a-input v-model:value="form.name" placeholder="请输入职务名称" />
        </a-form-item>
        <a-form-item label="状态" :rules="rules.status" name="status">
            <Switch v-model:checked="form.status" />
        </a-form-item>
    </a-form>
</template>
<script setup>
import { computed, reactive, ref } from 'vue'
import { useForm } from '@iframe/tools/mixins/FormMixins.js'
import { Switch } from '@iframe/tools/components'

const { validate, getForm, setForm } = useForm()

const formRef = ref()
const form = reactive({
    status: 0
})
const rules = reactive({
    code: { required: true, message: '请输入职务编码' },
    name: { required: true, message: '请输入职务名称' }
})

const disabled = computed(() => {
    return !!form.id
})

defineExpose({ validate: validate(formRef), getForm: getForm(form), setForm: setForm(form) })
</script>
